import { Component,  Injector, ViewChild, EventEmitter, Output } from '@angular/core';
import { appModuleAnimation } from '@shared/animations/routerTransition';
import { AppComponentBase } from '@shared/common/app-component-base';
import * as _ from 'lodash';
import { ModalDirective } from 'ngx-bootstrap';
import {  Base_UserCardServiceProxy } from '@shared/service-proxies/stock-service-proxies';

@Component({
    templateUrl: './tool-user-card-modal.component.html',
    animations: [appModuleAnimation()],
    selector: 'toolUserCardModal'
})
export class ToolUserCardModalComponent extends AppComponentBase {
    constructor(
        injector: Injector,
        private _base_UserCardServiceProxy: Base_UserCardServiceProxy
    ) {
        super(injector);
    }

    @ViewChild('createOrEditModal') modal: ModalDirective;

    @Output() modalSave: EventEmitter<any> = new EventEmitter<any>();


    saving = false;
    closed = false;
    active = false;
    userName = '';
    id;
    cardno = '';
    show(billid?: string): void {
        this.id = billid;
        //  this.active = true;
        this.closed = false;
        this.modal.show();

    }

    close(): void {
        //  this.active = false;
        this.modal.hide();
    }

    onHidden(event) {
        this.closed = true;
    }


    save() {
        this._base_UserCardServiceProxy.getUserInfoByCardNo(this.cardno).subscribe(result => {
      
            if (result.realName == null || result.realName == undefined) {
                this.notify.error(this.l('未查询到用户信息！'));
                return;
            }
            else {
                this.modalSave.emit(result);
                this.close();
            }
        })
    }






}
